<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>不同的循环子字符串</title>
</head>

<body>
  <script>
    var distinctEchoSubstrings = function (text) {
      const len = text.length
      let sum = 0
      let arr = []
      for (let i = 0; i < len; i++) {
        if (i + 1 > (len / 2)) { break }
        for (let j = 0; j < len; j++) {
          if (text.slice(j, j + (i + 1)) === text.slice(j + (i + 1), j + 2 * (i + 1))) {
            if (arr.indexOf(text.slice(j, j + (i + 1))) === -1) {
              arr.push(text.slice(j, j + (i + 1)))
              sum++
            }
          }
        }
      }
      return sum
    };
    console.log(distinctEchoSubstrings("abcabcabc"));
  </script>
</body>

</html>